﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="NameAndLabel.cs" company="" />
// <summary>
//   Defines various needed helper classes and structures.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Xompare.Helpers
{
    /// <summary>
    /// A name and label vector
    /// </summary>
    public class NameAndLabel
    {
        public NameAndLabel(string name, string label)
        {
            Name = name;
            Label = label;
        }

        /// <summary>
        /// Get a label or a name if label does not exist. Deal with 'null' cases as well.
        /// </summary>
        /// <param name="tag">The <see cref="NameAndLabel"/> object to convert to string.</param>
        /// <returns>A safe string name.</returns>
        public static string GetSafeName(NameAndLabel tag)
        {
            return tag == null
                ? string.Empty
                : !string.IsNullOrEmpty(tag.Label)
                    ? tag.Label
                    : tag.Name;
        }

        /// <summary>
        /// Gets the name set by the constructor
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// Gets the label set by the constructor
        /// </summary>
        public string Label { get; private set; }
    }
}
